package org.eae.eldf.dao.base.impl;

import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.eae.eldf.dao.base.IBaseParameterDao;
import org.eae.eldf.entity.base.BaseParameter;
import org.eae.eldf.framework.dao.JdbcDaoImpl;
import org.eae.eldf.framework.pager.Pagination;
import org.eae.eldf.framework.utils.StringUtil;
import org.springframework.stereotype.Repository;
/**
 * ****************************************************************************
 * @File name   :      BaseParameterDaoImpl.java
 *
 * @Author      :      qubibo
 *
 * @Date        :      2016-6-7
 *
 * @Copyright Notice: 
 * Copyright (c) 2016 Efast Serv. All  Rights Reserved.
 * This software is published under the terms of the Efast Software
 * License version 1.0, a copy of which has been included with this
 * distribution in the LICENSE.txt file.
 * 
 * 
 * ----------------------------------------------------------------------------
 * Date                   Who         Version        Comments
 * 2016-6-7 上午10:54:36        qubibo     1.0            Initial Version
 ****************************************************************************
 */
@Repository
public class BaseParameterDaoImpl extends JdbcDaoImpl implements IBaseParameterDao{

	@Override
	public Pagination<BaseParameter> queryListBaseParameter(
			Pagination<BaseParameter> pager, String searchValue) {
		// TODO Auto-generated method stub
		StringBuffer sql=new StringBuffer("select * from base_parameter p where p.valid = 0");
		List<Object> pars=new ArrayList<Object>();
		if(!StringUtil.isNullOrBlank(searchValue)){
			sql.append(" and p.module_name like ?");
			pars.add("%"+searchValue+"%");
		}
		if(StringUtils.isNotBlank(pager.getOrderBy()) && StringUtils.isNotBlank(pager.getSort())){
			sql.append(" order by "+pager.getOrderBy().toUpperCase()+" "+pager.getSort().toUpperCase());
		}else{
			sql.append(" order by p.create_time desc");
		}
		return this.queryListByPage(pager, sql.toString(),pars,BaseParameter.class);
	}

}
